<!--START JS-->
<i id="scriptTag">/static/js/console/coupon.js</i>
<link href="/static/css/plugins/footable/footable.core.css" rel="stylesheet">
<link href="/static/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
<link href="/static/css/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet">
<!--END JS-->

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2><?php echo $page_title; ?></h2>
        <p>您可在此进行<?php echo $page_title; ?></p>
    </div>
    <div class="col-lg-2"></div>
</div>

<!--START coupon-->
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5><?php echo $page_title; ?></h5>
                </div>
                <div class="ibox-content">
                    <div class="tab-container">
                        <ul class="nav nav-tabs">
                            <li class="active">
                                <a data-toggle="tab" href="#coupon-data-list" aria-expanded="true">优惠卷列表</a>	
                            </li>	
                            <li class="">
                                <a data-toggle="tab" href="#coupon-add-list" aria-expanded="false">优惠卷制作</a>	
                            </li>	
                        </ul>	
                        <div class="tab-content">
                            <div id="coupon-data-list" class="tab-pane active">
                                <div class="panel-body">
                                    <?php if (!$list) { ?>
                                        <h2 class="text-navy text-center">暂无数据...</h2>
                                    <?php } else { ?>
                                        <input type="text" class="form-control input-sm m-b-xs" id="filter" placeholder="Search for sth in table">
                                        <table class="footable table table-stripped toggle-arrow-tiny table-hover" id="data-table" data-page-size="8" data-filter="#filter">
                                            <thead>
                                                <tr>
                                                    <th>序号</th>
                                                    <th>门店名称</th>
                                                    <th>优惠信息</th>
                                                    <th>有效期</th>
                                                    <th>发放数</th>
                                                    <th>使用数</th>
                                                    <th>领取数</th>
                                                    <th>操作</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php foreach ($list as $item) { ?>
                                                    <tr>
                                                        <td><?php echo $item['coupon_id']; ?></td>
                                                        <td><?php echo $item['shop_name']; ?></td>
                                                        <td><?php echo $item['coupon_info']; ?></td>
                                                        <td><?php echo date('Y-m-d', $item['coupon_start']) . '至' . date('Y-m-d', $item['coupon_end']) ?></td>
                                                        <td><?php echo $item['coupon_count']; ?></td>
                                                        <td><?php echo $item['coupon_use']; ?></td>
                                                        <td><?php echo $item['coupon_receive']; ?></td>
                                                        <td>                             
                                                            <a href="/console/couponEdit/<?php echo $item['coupon_id']; ?>" class="edit-btn btn btn-bitbucket btn-primary" title="修改">    
                                                                <i class="fa fa-edit"></i>                        
                                                            </a>                           
                                                            <a href="#" data-id="<?php echo $item['coupon_id']; ?>" class="del-btn btn btn-bitbucket btn-danger" title="删除">     
                                                                <i class="fa fa-times"></i>                        
                                                            </a>                       
                                                        </td>
                                                    </tr>
                                                <?php } ?>
                                            </tbody>
                                            <tfoot>
                                                <tr>
                                                    <td colspan="4">
                                                        <ul class="pagination pull-right"></ul>
                                                    </td>
                                                </tr>
                                            </tfoot>
                                        </table>
                                    <?php } ?>
                                </div>
                            </div>	
                            <div id="coupon-add-list" class="tab-pane">
                                <div class="panel-body">
                                    <div class="form-group">
                                        <label>选择门店：</label>
                                        <select class="form-control" id="shop-chosen">
                                            <?php foreach ($create as $item) { ?>
                                                <option 
                                                    value="<?php echo $item['id']; ?>"
                                                    data-phone="<?php echo $item['shop_phone']; ?>"
                                                    data-address="<?php echo $item['shop_province'] . ' ' . $item['shop_city'] . ' ' . $item['shop_address']; ?>"
                                                    >
                                                        <?php echo $item['shop_name']; ?>
                                                </option>
                                            <?php } ?>
                                        </select>
                                    </div>
                                    <div class="form-group" id="branche-chosen">
                                        <label>选择分店：</label>
                                        <p id="branche-empty" class="text-navy" style="display: none;">该门店没有分店,默认使用门店地址</p>
                                        <select id="branche-not-empty" class="form-control" style="display: none;"></select>
                                        <script type="text/x-jquery-tmpl" id="branche-chosen-tmpl">
                                            <option value="{{= id}}" 
                                            data-phone="{{= branche_phone}}" data-address="{{= branche_province}} {{= branche_city}} {{= branche_address}}">
                                            {{= branche_name}}
                                            </option>
                                        </script>
                                    </div>
                                    <input type="hidden" value="" id="branche-id">
                                    <div class="form-group" >
                                        <label>地址明细：</label>
                                        <p id="address-detail"></p>
                                    </div>
                                    <div class="form-group">
                                        <label>优惠信息：</label>
                                        <input type="text" class="form-control" placeholder="请填写优惠信息" id="coupon-info">
                                    </div>
                                    <div class="form-group">
                                        <label>使用规则：</label>
                                        <textarea id="coupon-rule" class="form-control" style="min-height:150px;" placeholder="请填写使用规则"></textarea>
                                    </div>
                                    <div class="form-group">
                                        <label>发放数量：</label>
                                        <input id="coupon-count" type="number" class="form-control" placeholder="请填写发放数量">
                                    </div>
                                    <div class="form-group">
                                        <label>有效期：</label>
                                        <div class="input-daterange input-group" id="datepicker">
                                            <input type="text" class="input-sm form-control" value="" id="coupon-start">
                                            <span class="input-group-addon">至</span>
                                            <input type="text" class="input-sm form-control" value="" id="coupon-end">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <button id="save-btn" class="btn btn-primary">保存</button>
                                    </div>
                                </div>
                            </div>		
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--END coupon-->